﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Xml;

namespace SimpleText.Framework
{

public class Language
{
	public string Name { get; set; }
	public string Comment { get; set; }
	public string ShortName { get; set; }
	public string CultureName { get; set; }

	public void InitWithXml(XmlNode xmlNode)
	{
		Name = xmlNode.Attributes["name"].Value;
		ShortName = xmlNode.Attributes["shortName"].Value;
		CultureName = xmlNode.Attributes["cultureName"].Value;
		XmlNode commentNode = xmlNode.SelectSingleNode("comment");
		if (commentNode != null)
		{
			Comment = commentNode.InnerText;
		}
	}
	public string GetAsXml()
	{
		return GetAsXml("");
	}
	public string GetAsXml(string baseIndent)
	{
		string indent = "\t";
		string xml = "";

		xml += baseIndent + "<language name=\"" + Name + "\" shortName=\"" + ShortName + "\" cultureName=\"" + CultureName + "\">" + "\r\n";

		if (!String.IsNullOrEmpty(Comment))
		{
			xml += baseIndent + indent + "<comment><![CDATA[" + Comment + "]]></comment>" + "\r\n";
		}

		xml += baseIndent + "</language>" + "\r\n";

		return xml;
	}

}

}